package com.wsoft.system.controller;

import com.wsoft.response.ResponseResult;
import com.wsoft.system.query.role.menu.RoleMenuQuery;
import com.wsoft.system.service.ISysRoleMenuRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *  前端控制器
 * @author zgk
 * @since 2024年09月23日 09:18:25
 */
@RestController
@Tag(name = "角色菜单关系")
@RequestMapping("/sys/roleMenuRelation")
public class SysRoleMenuRelationController {

    @Resource
    private ISysRoleMenuRelationService roleMenuService;
    @Operation(summary = "根据角色id获取菜单列表", description = "根据角色id获取菜单列表")
    @GetMapping("/getMenuListByRoleId")
    public ResponseResult getMenuListByRoleId(@RequestParam("roleId") Long roleId) {
        return ResponseResult.success(roleMenuService.getMenuListByRoleId(roleId));
    }

    @Operation(summary = "根据角色id配置角色菜单关系", description = "根据角色id配置角色菜单关系")
    @PostMapping("/insertRelationByRoleId")
    public ResponseResult insertRelationByRoleId(@RequestBody RoleMenuQuery query) {
        return ResponseResult.success(roleMenuService.insertRelationByRoleId(query));
    }
}
